using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Network;
using MicroMsg.Protocol;
using System;
namespace MicroMsg.Scene
{
	public class NetSceneGetVerifyImage : NetSceneBaseEx<GetVerifyImgRequest, GetVerifyImgResponse, GetVerifyImgRequest.Builder>
	{
		private const string TAG = "NetSceneGetVerifyImg";
		public void doScene(string userName, string pwdMd5)
		{
			Log.smethod_4("NetSceneGetVerifyImg", "get verify image , user = " + userName);
			base.beginBuilder();
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(48);
			this.mBuilder.UserName = Util.toSKString(userName);
			this.mBuilder.Pwd = Util.toSKString(pwdMd5);
			this.mSessionPack.mConnectMode = 2;
			this.mSessionPack.mCmdID = 48;
			base.endBuilder();
		}
		protected override void onFailed(GetVerifyImgRequest request, GetVerifyImgResponse response)
		{
			EventCenter.postEvent(EventConst.ON_NETSCENE_AUTH_GETVERIFYIMGE_ERR, -800000, null);
		}
		protected override void onSuccess(GetVerifyImgRequest request, GetVerifyImgResponse response)
		{
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret == RetConst.MM_OK)
			{
				VerifyCodeArgs verifyCodeArgs = new VerifyCodeArgs();
				verifyCodeArgs.mImageSid = response.ImgSid.String;
				verifyCodeArgs.mImageBuf = response.ImgBuf.Buffer.ToByteArray();
				Log.smethod_5("NetSceneGetVerifyImg", "get verify image success , sid = " + verifyCodeArgs.mImageSid);
				EventCenter.postEvent(EventConst.ON_NETSCENE_AUTH_GETVERIFYIMGE_SUCCESS, verifyCodeArgs, null);
				return;
			}
			Log.smethod_1("NetSceneGetVerifyImg", "get verify image  failed,   ret = " + ret);
			EventCenter.postEvent(EventConst.ON_NETSCENE_AUTH_GETVERIFYIMGE_ERR, ret, null);
		}
		public static void testGetVerifyImage()
		{
			ServiceCenter.sceneGetVerifyImage.doScene("2312707430", Util.getCutPasswordMD5("halenhuang"));
		}
	}
}
